<template>
	<view class="mainpadding2">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 100rpx;" ></view>
		</view>
		<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="flexleft" v-if="item.is_n==0">
					<image :src="item.user_data.avatar" class="headimg" mode=""></image>
					<view class="hei_text margin_left bold main_size">{{item.user_data.nickname}}</view>
				</view>
				<view class="huang_text bold main_size" v-else>匿名使用者</view>
				<view class="xiaohui">{{http.returnDate(item.createtime*1000)}}</view>
			</view>
			<view class="margin_top">
				<u-rate :count="5" v-model="item.shop_pf" active-color="#FAB536" size="14" readonly></u-rate>
			</view>
			<view class="hui_text main_size margin_top">{{item.shop_txt}}</view>
			<view class="flexleft">
				<view class="itemimgBox flexcenter margin_top2" v-if="item.images_text.length" v-for="(ite,ind) in item.images_text" @click="lbtpriview(ind,item.images_text)" :key="ind">
					<image class="listleftimg radius" :src="ite" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				chudi: false
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			lbtpriview(index, arr) {
				var i = arr; //获取当前页面的轮播图数据
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: i //预览图片的地址，必須要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			init(isPage, page) {
				let _this = this
				let url = "/api/shop/evaluatelist"
				let data = {
					page: page || 1,
					limit: _this.limit,
					shop_id: uni.getStorageSync("shop_id"),
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						res.data.data.forEach(item => {
										let arr = item.images?item.images.split(","):[]
										let arr2 = []
										arr.forEach(value => {
											arr2.push(this.imgUrlUser + value)
										})
										this.$set(item, "images_text", arr2)
										if (item.user_data) {
											item.user_data.avatar = this.imgUrlUser + item.user_data.avatar
										}
									})
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// init(isPage, page) { //提現記錄
			// 	let _this = this;
			// 	let url = '/api/shop/evaluatelist'
			// 	this.http.request(url, 'POST', {
			// 		page_num: page || 1,
			// 		shop_id: uni.getStorageSync("shop_id"),
			// 	}, false, false, true).then(res => {
			// 		if (res.code == 1) {
			// 			res.data.forEach(item => {
			// 				let arr = item.images?item.images.split(","):[]
			// 				let arr2 = []
			// 				arr.forEach(value => {
			// 					arr2.push(this.imgUrlUser + value)
			// 				})
			// 				this.$set(item, "images_text", arr2)
			// 				if (item.user_data) {
			// 					item.user_data.avatar = this.imgUrlUser + item.user_data.avatar
			// 				}
			// 			})
			// 			if (isPage == true) {
			// 				_this.list.data = _this.list.data.concat(res.data);
			// 			} else {
			// 				_this.list.data = res.data;
			// 				this.chudi = false
			// 				this.page = 1
			// 			}
			// 		} else {
			// 			this.chudi = true
			// 		}
			// 	}).catch(err => {
			// 		this.http.toast(err.msg);
			// 	})
			// },
			// onReachBottom() {
			// 	let _this = this;
			// 	let list = _this.list;
			// 	let page = _this.page;
			// 	if (this.chudi) {
			// 		return false;
			// 	}
			// 	page++;
			// 	_this.page = page;
			// 	_this.init(true, page);
			// },
		}
	}
</script>

<style lang="scss" scoped>
	.beihuolable {
		background-color: #fff3e6;
		padding: 5rpx 10rpx;
		border: 1rpx solid #FF8505;
	}
</style>